import { action, controller, routeData } from "maishu-node-mvc";
import { errors } from "../errors";
import { auth } from "../services/mini-program";

@controller()
export class AuthController {
    @action("/user/login")
    login(@routeData { code }: { code: string }) {
        if (!code) throw errors.routeDataFieldNull("code");
        return auth.code2Session(code).then(async r => {
            // let o = await s.login({ openid: r.openid });
            // return o;
        })
    }

    @action("/user/temp")
    temp() {
        // let s = new PermissionService();
        // return s.login({ openid: "o2Q3T5HIrmUB9gCZ4lZ1jvjdMbaE" })
    }
}
